﻿function submitOnclick(C) {
  var userID = document.getElementById('userid').value;
  var passWord = document.getElementById('password').value;
  var infoJson = {
    username : userID,
    password : passWord,
  };
  var infoMsg = postMD5(infoJson);
  if(userID == ''){
    alert('请输入用户名');
  }else if(passWord == ''){
    alert('请输入密码');
  }else{
    //alert('userID:'+userID+'--passWord:'+$MD5.getMD5(passWord));
    console.log(JSON.stringify(infoMsg));
    $.ajax({
        url: 'http://192.168.1.118/api/UserAction/login',//'/api/UserAction/login',
        type:'POST',
		contentType:"application/json; charset=utf-8",  //  ---->  问题就在这里了
        data:infoMsg,//infoJson,//infoMsg,
        timeout:5000,    //超时时间
        dataType:'json',    //返回的数据格式
        success:function(data,textStatus,jqXHR){
            console.log(JSON.stringify(data));
            console.log(textStatus);
            if(data.State == 'true'){
              var userNameForEP = escape(data.Data[0].userName);//中文字符编码
              var frameURL = 'index.html?userID='+userID+'&userName='+userNameForEP;
              window.location.href=frameURL;
            }else if (data.State == 'false') {
              alert(data.Message);
            };
        },
        error:function(xhr,textStatus){
            console.log('错误');
            console.log(textStatus);
        },
    })
  }
}
function postMD5(G, A) {
	if (G) {
		A = A || "stdsjDH";
		var E = new Array();
		for (var B in G) {
			E.push((B + G[B]).toUpperCase())
		}
		var D = Date.parse(new Date());
		E.push(("TimeStamp" + D).toUpperCase());
		E.sort();
		var F = "";
		for (var C = 0; C < E.length; C++) {
			F += E[C]
		}
		G.TimeStamp = D;
		G.secretkey = $MD5.getMD5(F + A);
		return G
	} else {
		return G
	}
}
